package com.joolun.web.controller.mall;


import java.util.HashMap;
import java.util.List;

import com.joolun.common.core.controller.BaseController;
import com.joolun.common.core.domain.AjaxResult;
import com.joolun.mall.domain.PayData;
import com.joolun.mall.domain.WxData;
import com.joolun.mall.dto.QueryDateDTO;
import com.joolun.mall.service.DataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/data")
@Api(value = "data", tags = "数据统计")
public class DataController extends BaseController {

    private final DataService dataService;

    @ApiOperation(value = "首页数据统计")
    @GetMapping("/index")
    public AjaxResult getData(QueryDateDTO queryDateDTO) {
        List<PayData> payData = dataService.selectOrder(queryDateDTO);
        WxData wxData = dataService.selectWxData(queryDateDTO);
        HashMap data = new HashMap();
        data.put("order", payData);
        data.put("wx", wxData);
        return AjaxResult.success(data);
    }
}
